package project1.entity;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class ShoppingCart extends LinkedHashMap<Book, Integer> {
    @Override
    public String toString() {
        List<String> result = new ArrayList<>();
        for (Map.Entry<Book, Integer> entry : super.entrySet()) {
            Book book = entry.getKey();
            Integer count = entry.getValue();
            result.add(book + " 购买了:" + count + "件");
        }
        return String.join("\r\n", result);
    }
}
